import { SEntityId } from "../../../../Message/Public/SEntityId";
import { IEntity } from "../../scene/player/IEntity";
import { GTextFormat } from "../../../common/GTextFormat";
import { Language } from "../../../../extend/language/Language";
import { SearchPlayerItem } from "./SearchPlayerItem";
type int = number;
//class SearchPlayerPanel
    
    export  class SearchPlayerPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._itemArr = [];
            this.init();
            return;
        }

        public get curPlayerId(): SEntityId
        {
            return this._curPlayerId;
        }

        public get curPlayerInfo(): IEntity
        {
            return this._curPlayerInfo;
        }

        /* internal  */init(): void
        {
            var loc1=new GTextFormat("", 12, 16711601, null, null, null, null, null, flash.text.TextFormatAlign.CENTER);
            var loc2=this.createTextField(0, 0, 120, 25, Language.getString(90154), loc1);
            var loc3=this.createTextField(120, 0, 30, 25, Language.getString(90155), loc1);
            var loc4=this.createTextField(190, 0, 30, 25, Language.getString(90156), loc1);
            this.graphics.moveTo(0, 25);
            this.graphics.lineStyle(0.8, 282466);
            this.graphics.lineTo(255, 25);
            this.createItem();
            return;
        }

        /* internal  */createTextField(arg1: int, arg2: int, arg3: int, arg4: int, arg5: string, arg6: Object /* flash.text.TextFormat */): Object /* flash.text.TextField */
        {
            var loc1=null;
            (loc1 = new Object /* flash.text.TextField */()).selectable = false;
            loc1.x = arg1;
            loc1.y = arg2;
            loc1.width = arg3;
            loc1.height = arg4;
            loc1.htmlText = arg5;
            loc1.setTextFormat(arg6);
            addChild(loc1);
            return loc1;
        }

        /* internal  */createItem(): void
        {
            var loc2=0;
            var loc3=null;
            var loc1=0;
            loc2 = 25;
            var loc4=0;
            while (loc4 < 5) 
            {
                loc3 = new SearchPlayerItem();
                loc3.x = loc1;
                loc3.y = loc2;
                loc3.addEventListener(flash.events.MouseEvent.CLICK, this.onItemClickHandler);
                addChild(loc3);
                this._itemArr.push(loc3);
                loc2 = loc2 + loc3.height;
                ++loc4;
            }
            return;
        }

        public updatePlayer(arg1: Array<any>): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._itemArr.length) 
            {
                loc1 = this._itemArr[loc2] as SearchPlayerItem;
                loc1.updateData(arg1[loc2]);
                if (loc1.isDraw) 
                {
                    loc1.clearBgColor();
                }
                ++loc2;
            }
            if (arg1.length > 0 && !(arg1 == null)) 
            {
                loc1 = this._itemArr[0] as SearchPlayerItem;
                loc1.drawGrayColor();
                this._curPlayerId = loc1.entity;
            }
            else 
            {
                this._curPlayerId = null;
            }
            return;
        }

        /* internal  */onItemClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._itemArr.length) 
            {
                loc1 = this._itemArr[loc2] as SearchPlayerItem;
                if (loc1.isDraw) 
                {
                    loc1.clearBgColor();
                }
                ++loc2;
            }
            loc1 = arg1.target as SearchPlayerItem;
            this._curPlayerId = loc1.entity;
            this._curPlayerInfo = loc1.playerInfo;
            loc1.drawGrayColor();
            return;
        }

        /* internal */ /* var */_curPlayerId: SEntityId;

        /* internal */ /* var */_curPlayerInfo: IEntity;

        /* internal */ /* var */_itemArr: Array<any>;
    }
